Skip to content

获取 url 的 fragment、host、path、port、protocol

用 url_extract_fragment 函数获取 url 的 fragment,用 url_extract_host 函数获取 url 的 host,用 url_extract_path 函数获取 url 的 path,用 url_extract_port 函数获取 url 的 port,用 url_extract_protocol 函数获取 agreement

SQL
* |
select
  url_extract_fragment(
    'https://sls.console.aliyun.com/#/project/dashboard-demo/categoryList'
  ) as fragment,
  url_extract_host(
    'https://sls.console.aliyun.com/#/project/dashboard-demo/categoryList'
  ) as host,
  url_extract_path(
    'https://sls.console.aliyun.com/lognext/project/dashboard-all/logsearch/nginx-demo?accounttraceid=d6241a173f88471c91d3405cda010ff5ghdw'
  ) as path,
  url_extract_port('http://localhost:8080/lognext/profile') as port,
  url_extract_protocol('http://localhost:8080/lognext/profile') as agreement

SQL查询结果样例:

样例图片